#pragma once
#include<stdio.h>
#include<time.h>

#define DEBUG 0
#define INFO 1
#define ERR 2
#define DEFAULT_LOG_LEVEL DEBUG

#define LOG(level,format,...) do \
{\
    if(level<DEFAULT_LOG_LEVEL) break;\
    time_t now=time(NULL);\
    struct tm* str_tm=localtime(&now);\
    char strtime[32]={0};\
    strftime(strtime,sizeof(strtime)-1,"%H:%M:%S",str_tm);\
    /* code */\
    fprintf(stdout,"[%s][%s:%d]" format "\n",strtime,__FILE__,__LINE__,##__VA_ARGS__);\
} while (0);

#define DEBUG_LOG(format,...) LOG(INFO,format,##__VA_ARGS__);
#define INFO_LOG(format,...) LOG(INFO,format,##__VA_ARGS__);
#define ERROR_LOG(format,...) LOG(INFO,format,##__VA_ARGS__);